|
speaker2 2.2.1
|
API for configuring and manipulating Speaker 2 Click driver. More...
Topics | |
| Speaker 2 Commands List | |
| List of commands of Speaker 2 Click driver. | |
| Speaker 2 Registers Settings | |
| Settings for registers of Speaker 2 Click driver. | |
| Speaker 2 MikroBUS Map | |
| MikroBUS pin mapping of Speaker 2 Click driver. | |
Functions | |
| void | speaker2_cfg_setup (speaker2_cfg_t *cfg) |
| Speaker 2 configuration object setup function. | |
| err_t | speaker2_init (speaker2_t *ctx, speaker2_cfg_t *cfg) |
| Speaker 2 initialization function. | |
| err_t | speaker2_default_cfg (speaker2_t *ctx) |
| Speaker 2 default configuration function. | |
| err_t | speaker2_send_command (speaker2_t *ctx, uint8_t cmd, uint8_t *payload, uint16_t payload_len) |
| Speaker 2 send command function. | |
| void | speaker2_set_io5_pin (speaker2_t *ctx, uint8_t state) |
| Speaker 2 set IO5 pin function. | |
| uint8_t | speaker2_get_rdy_pin (speaker2_t *ctx) |
| Speaker 2 get RDY pin function. | |
| uint8_t | speaker2_get_int_pin (speaker2_t *ctx) |
| Speaker 2 get INT pin function. | |
| err_t | speaker2_wait_ready (speaker2_t *ctx) |
| Speaker 2 wait ready function. | |
| err_t | speaker2_wait_status (speaker2_t *ctx, uint8_t mask, uint8_t state) |
| Speaker 2 wait status function. | |
| err_t | speaker2_wait_idle (speaker2_t *ctx) |
| Speaker 2 wait idle function. | |
| err_t | speaker2_check_communication (speaker2_t *ctx) |
| Speaker 2 check communication function. | |
| err_t | speaker2_read_status (speaker2_t *ctx, uint8_t *int_status) |
| Speaker 2 read status function. | |
| err_t | speaker2_clear_interrupt (speaker2_t *ctx, uint8_t *int_status) |
| Speaker 2 clear interrupt function. | |
| err_t | speaker2_read_device_id (speaker2_t *ctx, speaker2_device_id_t *device_id) |
| Speaker 2 read device ID function. | |
| err_t | speaker2_power_up (speaker2_t *ctx) |
| Speaker 2 power up function. | |
| err_t | speaker2_power_down (speaker2_t *ctx) |
| Speaker 2 power down function. | |
| err_t | speaker2_reset_device (speaker2_t *ctx) |
| Speaker 2 reset device function. | |
| err_t | speaker2_memory_erase (speaker2_t *ctx, uint32_t address) |
| Speaker 2 memory erase function. | |
| err_t | speaker2_chip_erase (speaker2_t *ctx) |
| Speaker 2 chip erase function. | |
| err_t | speaker2_flash_write (speaker2_t *ctx, uint32_t address, uint8_t *data_in, uint16_t data_len) |
| Speaker 2 flash write function. | |
| err_t | speaker2_flash_read (speaker2_t *ctx, uint32_t address, uint8_t *data_out, uint16_t data_len) |
| Speaker 2 flash read function. | |
| err_t | speaker2_write_binary (speaker2_t *ctx, uint32_t address, const uint8_t *data_in, uint16_t data_len) |
| Speaker 2 write binary function. | |
| err_t | speaker2_write_cfg_reg (speaker2_t *ctx, uint8_t reg, uint8_t data_in) |
| Speaker 2 write configuration register function. | |
| err_t | speaker2_read_cfg_reg (speaker2_t *ctx, uint8_t reg, uint8_t *data_out) |
| Speaker 2 read configuration register function. | |
| err_t | speaker2_set_clock_cfg (speaker2_t *ctx, uint8_t clk_cfg) |
| Speaker 2 set clock configuration function. | |
| err_t | speaker2_read_clock_cfg (speaker2_t *ctx, uint8_t *clk_cfg) |
| Speaker 2 read clock configuration function. | |
| err_t | speaker2_spi_audio_write (speaker2_t *ctx, uint8_t *data_in, uint16_t data_len) |
| Speaker 2 SPI audio write function. | |
| err_t | speaker2_pcm_audio_read (speaker2_t *ctx, uint16_t *data_out, uint16_t data_len) |
| Speaker 2 PCM audio read function. | |
| err_t | speaker2_play_voice (speaker2_t *ctx, uint16_t index) |
| Speaker 2 play voice function. | |
| err_t | speaker2_play_voice_loop (speaker2_t *ctx, uint16_t index, uint16_t loop_cnt) |
| Speaker 2 play voice loop function. | |
| err_t | speaker2_play_macro (speaker2_t *ctx, uint16_t index) |
| Speaker 2 play macro function. | |
| err_t | speaker2_play_silence (speaker2_t *ctx, uint8_t len) |
| Speaker 2 play silence function. | |
| err_t | speaker2_stop_play (speaker2_t *ctx) |
| Speaker 2 stop play function. | |
| err_t | speaker2_stop_loop_play (speaker2_t *ctx) |
| Speaker 2 stop loop play function. | |
API for configuring and manipulating Speaker 2 Click driver.
Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.
| void speaker2_cfg_setup | ( | speaker2_cfg_t * | cfg | ) |
Speaker 2 configuration object setup function.
This function initializes Click configuration structure to initial values.
| [out] | cfg | : Click configuration structure. See speaker2_cfg_t object definition for detailed explanation. |
| err_t speaker2_check_communication | ( | speaker2_t * | ctx | ) |
Speaker 2 check communication function.
This function verifies communication with the device by checking the device ID.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
0 - Success, -1 - Communication error. | err_t speaker2_chip_erase | ( | speaker2_t * | ctx | ) |
Speaker 2 chip erase function.
This function erases the entire chip memory.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
0 - Success, -1 - Error. | err_t speaker2_clear_interrupt | ( | speaker2_t * | ctx, |
| uint8_t * | int_status ) |
Speaker 2 clear interrupt function.
This function clears the interrupt register and optionally stores the interrupt status.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [out] | int_status | : Pointer to the variable for storing interrupt status (optional). |
0 - Success, -1 - Error. | err_t speaker2_default_cfg | ( | speaker2_t * | ctx | ) |
Speaker 2 default configuration function.
This function executes a default configuration of Speaker 2 Click board.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
0 - Success, -1 - Error. See #err_t definition for detailed explanation. | err_t speaker2_flash_read | ( | speaker2_t * | ctx, |
| uint32_t | address, | ||
| uint8_t * | data_out, | ||
| uint16_t | data_len ) |
Speaker 2 flash read function.
This function reads data from the flash memory at the specified address.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [in] | address | : Flash memory address. |
| [out] | data_out | : Pointer to the buffer for storing the read data. |
| [in] | data_len | : Number of bytes to read. |
0 - Success, -1 - Error. | err_t speaker2_flash_write | ( | speaker2_t * | ctx, |
| uint32_t | address, | ||
| uint8_t * | data_in, | ||
| uint16_t | data_len ) |
Speaker 2 flash write function.
This function writes data to the flash memory at the specified address.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [in] | address | : Flash memory address. |
| [in] | data_in | : Pointer to the data to write. |
| [in] | data_len | : Number of bytes to write. |
0 - Success, -1 - Error. | uint8_t speaker2_get_int_pin | ( | speaker2_t * | ctx | ) |
Speaker 2 get INT pin function.
This function returns the INT pin logic state.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| uint8_t speaker2_get_rdy_pin | ( | speaker2_t * | ctx | ) |
Speaker 2 get RDY pin function.
This function returns the RDY pin logic state.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| err_t speaker2_init | ( | speaker2_t * | ctx, |
| speaker2_cfg_t * | cfg ) |
Speaker 2 initialization function.
This function initializes all necessary pins and peripherals used for this Click board.
| [out] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [in] | cfg | : Click configuration structure. See speaker2_cfg_t object definition for detailed explanation. |
0 - Success, -1 - Error. See #err_t definition for detailed explanation. | err_t speaker2_memory_erase | ( | speaker2_t * | ctx, |
| uint32_t | address ) |
Speaker 2 memory erase function.
This function erases the 1kB sector of memory containing the specified address.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [in] | address | : Memory address to erase. |
0 - Success, -1 - Error. | err_t speaker2_pcm_audio_read | ( | speaker2_t * | ctx, |
| uint16_t * | data_out, | ||
| uint16_t | data_len ) |
Speaker 2 PCM audio read function.
This function reads PCM audio data from the device via the SPI interface.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [out] | data_out | : Pointer to the buffer for storing the read PCM audio data. |
| [in] | data_len | : Length of the audio data to read. |
0 - Success, -1 - Error. | err_t speaker2_play_macro | ( | speaker2_t * | ctx, |
| uint16_t | index ) |
Speaker 2 play macro function.
This function executes a macro command at the specified index.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [in] | index | : Macro index to execute. |
0 - Success, -1 - Error. | err_t speaker2_play_silence | ( | speaker2_t * | ctx, |
| uint8_t | len ) |
Speaker 2 play silence function.
This function plays a period of silence for a specified duration.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [in] | len | : Duration of silence in 32 milliseconds steps. |
0 - Success, -1 - Error. | err_t speaker2_play_voice | ( | speaker2_t * | ctx, |
| uint16_t | index ) |
Speaker 2 play voice function.
This function plays a voice at the specified index.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [in] | index | : Voice index to play. |
0 - Success, -1 - Error. | err_t speaker2_play_voice_loop | ( | speaker2_t * | ctx, |
| uint16_t | index, | ||
| uint16_t | loop_cnt ) |
Speaker 2 play voice loop function.
This function plays a voice in a loop for a specified number of iterations.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [in] | index | : Voice index to play. |
| [in] | loop_cnt | : Number of iterations to loop. |
0 - Success, -1 - Error. | err_t speaker2_power_down | ( | speaker2_t * | ctx | ) |
Speaker 2 power down function.
This function powers down the device and waits for the appropriate status.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
0 - Success, -1 - Error. | err_t speaker2_power_up | ( | speaker2_t * | ctx | ) |
Speaker 2 power up function.
This function powers up the device and configures GPIO functionality.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
0 - Success, -1 - Error. | err_t speaker2_read_cfg_reg | ( | speaker2_t * | ctx, |
| uint8_t | reg, | ||
| uint8_t * | data_out ) |
Speaker 2 read configuration register function.
This function reads a value from a configuration register.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [in] | reg | : Register address. |
| [out] | data_out | : Pointer to the buffer for storing the read value. |
0 - Success, -1 - Error. | err_t speaker2_read_clock_cfg | ( | speaker2_t * | ctx, |
| uint8_t * | clk_cfg ) |
Speaker 2 read clock configuration function.
This function reads the current clock configuration from the device.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [out] | clk_cfg | : Pointer to the buffer for storing the clock configuration. |
0 - Success, -1 - Error. | err_t speaker2_read_device_id | ( | speaker2_t * | ctx, |
| speaker2_device_id_t * | device_id ) |
Speaker 2 read device ID function.
This function reads the device ID and stores it in the provided device ID structure.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [out] | device_id | : Pointer to the structure for storing the device ID. |
0 - Success, -1 - Error. | err_t speaker2_read_status | ( | speaker2_t * | ctx, |
| uint8_t * | int_status ) |
Speaker 2 read status function.
This function reads the device status and optionally stores the interrupt status.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [out] | int_status | : Pointer to the variable for storing interrupt status (optional). |
0 - Success, -1 - Error. | err_t speaker2_reset_device | ( | speaker2_t * | ctx | ) |
Speaker 2 reset device function.
This function resets the device by sending a reset command.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
0 - Success, -1 - Error. | err_t speaker2_send_command | ( | speaker2_t * | ctx, |
| uint8_t | cmd, | ||
| uint8_t * | payload, | ||
| uint16_t | payload_len ) |
Speaker 2 send command function.
This function writes a desired number of data bytes to the selected command and reads response by using SPI serial interface.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [in] | cmd | : Command byte. |
| [in,out] | payload | : Command payload to be written. Outputs command response. |
| [in] | payload_len | : Command payload/response length. |
0 - Success, -1 - Error. See #err_t definition for detailed explanation. | err_t speaker2_set_clock_cfg | ( | speaker2_t * | ctx, |
| uint8_t | clk_cfg ) |
Speaker 2 set clock configuration function.
This function sets the clock configuration for the device.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [in] | clk_cfg | : Clock configuration value. |
0 - Success, -1 - Error. | void speaker2_set_io5_pin | ( | speaker2_t * | ctx, |
| uint8_t | state ) |
Speaker 2 set IO5 pin function.
This function sets the IO5 pin logic state.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [in] | state | : Pin logic state. |
| err_t speaker2_spi_audio_write | ( | speaker2_t * | ctx, |
| uint8_t * | data_in, | ||
| uint16_t | data_len ) |
Speaker 2 SPI audio write function.
This function sends audio data to the device via the SPI interface for decoding.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [in] | data_in | : Pointer to the audio data to send. |
| [in] | data_len | : Length of the audio data. |
0 - Success, -1 - Error. | err_t speaker2_stop_loop_play | ( | speaker2_t * | ctx | ) |
Speaker 2 stop loop play function.
This function stops any ongoing looped playback.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
0 - Success, -1 - Error. | err_t speaker2_stop_play | ( | speaker2_t * | ctx | ) |
Speaker 2 stop play function.
This function stops any ongoing playback of voice or macro.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
0 - Success, -1 - Error. | err_t speaker2_wait_idle | ( | speaker2_t * | ctx | ) |
Speaker 2 wait idle function.
This function waits for the device to enter an idle state.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
0 - Success, -1 - Timeout error. | err_t speaker2_wait_ready | ( | speaker2_t * | ctx | ) |
Speaker 2 wait ready function.
This function waits for the RDY pin to be set, indicating that the device is ready.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
0 - Success, -1 - Timeout error. | err_t speaker2_wait_status | ( | speaker2_t * | ctx, |
| uint8_t | mask, | ||
| uint8_t | state ) |
Speaker 2 wait status function.
This function waits until the device status matches the given mask and state.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [in] | mask | : Status mask. |
| [in] | state | : Desired status state. |
0 - Success, -1 - Timeout error. | err_t speaker2_write_binary | ( | speaker2_t * | ctx, |
| uint32_t | address, | ||
| const uint8_t * | data_in, | ||
| uint16_t | data_len ) |
Speaker 2 write binary function.
This function writes binary data to the flash memory at the specified address. It divides the data into smaller chunks if the total data length exceeds the payload limit.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [in] | address | : Flash memory address to write to. |
| [in] | data_in | : Pointer to the binary data to write. |
| [in] | data_len | : Total length of the binary data. |
0 - Success, -1 - Error. | err_t speaker2_write_cfg_reg | ( | speaker2_t * | ctx, |
| uint8_t | reg, | ||
| uint8_t | data_in ) |
Speaker 2 write configuration register function.
This function writes a value to a configuration register.
| [in] | ctx | : Click context object. See speaker2_t object definition for detailed explanation. |
| [in] | reg | : Register address. |
| [in] | data_in | : Data to write. |
0 - Success, -1 - Error.